<template>
  <div>
    <page-header></page-header>

    <div class="page-body">
      <div class="page-body1">
        <page-side></page-side>
      </div>

      <div class="page-body2">
        <div>
          <div class="person_title">
            <div class="person_left">个人信息</div>
            <div class="person_right">
              <span>编辑</span>
              <span>保存</span>
              <span>退出</span>
            </div>
          </div>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="基本信息" name="first">
              <div>
                <el-form :label-position="labelPosition" label-width="100px" :model="persondata">
                  <el-form-item label="姓名" prop="username">
                    <el-input v-model="persondata.username" placeholder></el-input>
                  </el-form-item>
                  <el-form-item label="性别" prop="discribe">
                    <el-input v-model="persondata.sex"></el-input>
                  </el-form-item>
                  <el-form-item label="专业" prop="price">
                    <el-input v-model="persondata.professional"></el-input>
                  </el-form-item>
                  <el-form-item label="联系QQ" prop="qq">
                    <el-input v-model="persondata.qq"></el-input>
                  </el-form-item>
                  <el-form-item label="联系号码" prop="phone">
                    <el-input v-model="persondata.phone"></el-input>
                  </el-form-item>
                  <el-form-item label="联系微信" prop="wechat">
                    <el-input v-model="persondata.wechat"></el-input>
                  </el-form-item>
                  <el-form-item label="出生日期" prop="releasetime">
                    <el-input v-model="persondata.birthdate"></el-input>
                  </el-form-item>
                  <el-form-item label="联系地址" prop="releaseaddress">
                    <el-input v-model="persondata.addresss"></el-input>
                  </el-form-item>
                </el-form>
              </div>
            </el-tab-pane>
            <el-tab-pane label="我的头像" name="second">
              <div>
                <el-upload
                  class="avatar-uploader"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :show-file-list="true"
                  list-type="picture"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
              </div>
            </el-tab-pane>
            <el-tab-pane label="我的签名" name="third">
              <div class="person_sign">
                <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
                  <el-form-item label="我的签名" prop="sign">
                    <el-input  type="textarea" v-model="persondata.sign"></el-input>
                  </el-form-item>
                </el-form>
              </div>
            </el-tab-pane>
            <el-tab-pane label="认证状态" name="fourth">
              <div class="status">
                已认证
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>

        <page-footer></page-footer>
      </div>
    </div>
  </div>
</template>

<script>
import PageHeader from '@/components/pages/pageheader'
import PageSide from '@/components/pages/PageSide'
import PageContent from '@/components/pages/PageContent'
import PageFooter from '@/components/pages/PageFooter'

export default {
  name: 'Person',
  components: { PageHeader, PageSide, PageContent, PageFooter },
  data () {
    return {
      imageUrl: '/static/shopcard/6.jpg', // 头像图片
      labelPosition: 'left', // 位置
      activeName: 'second', // 默认选中
      // 个人数据
      persondata: {
        username: '',
        sex: '',
        qq: '',
        phone: '',
        wechat: '',
        email: '',
        professional: '',
        birthdate: '',
        address: '',
        sign: '111111111111'
      }
    }
  },
  methods: {
    // 导航栏切换
    handleClick (tab, event) {
      console.log(tab, event)
    },
    // 上传图片
    handleAvatarSuccess (res, file) {
      this.imageUrl = URL.createObjectURL(file.raw)
    },
    beforeAvatarUpload (file) {
      const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    }
  }
}
</script>

<style scoped>
.person_sign{
  height: 400px;
  line-height: 400px;
}
/* r------------------认证--------------------- */
.status{
  height: 400px;
  font-size: 40px;
  color: #1296db;
  text-align: center;
  line-height: 400px;
}
/* -------------------------------------头部-------------------- */
.person_title {
  display: flex;
  background-color: #1296db;
  font-size: 30px;
  justify-content: center;
  align-items: center;
  letter-spacing: 10px;
  padding: 10px 0;
  margin-bottom: 30px;
  border-radius: 5px;
  color: white;
  text-align: center;
}
.person_left {
  flex: 1;
}
.person_right {
  font-size: 14px;
  letter-spacing: 5px;
  width: 200px;
}
/* ------------------------------------------------------------------------------ */
.page-body {
  padding-top: 80px;
  padding-right: 20px;
  padding-left: 20px;
  display: flex;
  width: 98%;
}
.page-body1 {
  width: 13%;
  display: block;
  overflow: auto;
}
.page-body2 {
  width: 87%;
}
/* --------------------上传图片--------------------- */
.avatar-uploader .el-upload {
  border: 2px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
